﻿using System.Collections.Generic;
using System.Xml;

using pt=System.UInt32;

namespace RDLC
{
   public class DataValue
   {
      public string Name;
      public string Value;
   }

   public class RDLPosition
   {
      public RDLPosition(pt top, pt left, pt? width, pt? height)
      {
         Top = top;
         Left = left;
         Width = width;
         Height = height;
      }

      public void Write(XmlTextWriter writer)
      {
         writer.WriteElementString("Top", Top + "pt");
         writer.WriteElementString("Left", Left + "pt");
         if(Width.HasValue)
            writer.WriteElementString("Width", Width.Value + "pt");
         if(Height.HasValue)
            writer.WriteElementString("Height", Height.Value + "pt");
      }

      public pt Top;
      public pt Left;
      public pt? Width
      {
         get { return _Width; }
         set
         {
            if(!_Width.HasValue)
               _Width = new pt();
            _Width = value;
         }
      }
      private pt? _Width;
      public pt? Height;
   }

   public enum RDLUnit
   {
      CM,
      MM,
      IN,
      PT,
      PC
   };

   public enum RDLPageBreakLocation
   {
      Start,
      End,
      StartAndEnd,
      Between
   };

   public class RDLReportItems
   {
      public List<ReportItem> Items = new List<ReportItem>();

      public void Add(ReportItem item)
      {
         Items.Add(item);
      }

      public void AddRange(IEnumerable<ReportItem> items)
      {
         Items.AddRange(items);
      }

      public void Write(XmlTextWriter writer)
      {
         if(Items.Count != 0)
         {
            writer.WriteStartElement("ReportItems");

            foreach(ReportItem item in Items)
            {
               item.Write(writer);
            }

            writer.WriteEndElement(); // ReportItems         
         }
      }
   }

   public class RDLPageBreak
   {
      public RDLPageBreak(RDLPageBreakLocation pageBreakLocation)
      {
         PageBreakLocation = pageBreakLocation;
      }

      public RDLPageBreakLocation PageBreakLocation;
      // public BreakTypeT BreakType todo: Implement BreakType for RDLPageBreak;
      public string PageName; // Optional
      public int? SetPageNumber;
   }
}
